<?php
namespace app\models;

use yii;
use yii\db\Query;

class CommonModel
{
    use \app\lib\Redis;

    public function get_all_exchange_rate()
    {
        $redis_key = "exchange:rate";
        $redis = $this->getInstance();
        if ($list = $redis->get($redis_key)) {
            return $list;
        } else {
            $db = new Query();
            $list = $db->select('*')
                ->from(yii::$app->db->tablePrefix.'exchange_reate')
                ->all();
            $data = json_encode($list);
            $redis->setex($redis_key, 3600*24, $data);
            return $data;
        }
    }
}
